import React from "react";
import { Row, Col, Menu, Popover} from "antd";
import {connect} from 'react-redux';
import Cookie from 'react-cookies';
import hoc from "./hoc";
import PopoverContent from '../../pages/PC/member/outlogin';
import IconFont from "../iconfont";
import Css from "../../assets/css/pc/nav/index.css";
import LogoImg from "../../assets/images/pc/nav/gat_logo.png";

const TopNavComponent = hoc((props) => {
    const items = [
        { label: '我的首页', key: window.base.config.path + "home/index"  }, // 菜单项务必填写 key
        { label: '全部应用', key: window.base.config.path + "home/myApp" },
        { label: '我的流程', key: window.base.config.path + "process" },
        { label: 'EHR', key: window.base.config.path + "home/EHR" },
        { label: '关爱通知识库', key: window.base.config.path + "home/alipay" },
    ];
  return (
    <header className={Css["topNav"]}>
      <Row align="middle">
        <Col span={4}>
          <div className={Css["topNavLogo"]}>
            <img src={LogoImg} alt={"logo"} />
          </div>
        </Col>
        <Col span={16}>
          <Menu
            onClick={props.handleClick}
            selectedKeys={props.selectedKeys}
            mode="horizontal"
            className={Css["antdMenu"]}
            forceSubMenuRender={true}
            items={items}
          />
        </Col>
        <Col span={4}>
            {
                Cookie.load('access_token')? //登录
                    <Popover
                        overlayClassName={Css["userPopover"]}
                        content={<PopoverContent/>}
                        trigger="click"
                        placement="bottomRight"
                    >
                        <div className={Css["userBox"]}>
                            <div className={Css["userName"]}>{props.state.redGetUseInfo.useName}</div>
                            <IconFont
                                className={Css["topNavIcn"]}
                                type="icon-gatmgr31shezhi"
                            />
                        </div>
                    </Popover>
                    : //未登录
                    <div className={Css['loginBOx']}>
                        <div className={Css['loginIn']+' m5'} onClick={props.goPage.bind(this,'login')}>登录</div>
                        <div className={Css['loginIn']+' m5'} onClick={props.goPage.bind(this,'register')}>注册</div>
                    </div>

            }
        </Col>
      </Row>
    </header>
  );
});
export default connect((state)=>{
    return{
        state:state
    }
})(TopNavComponent);
